<template>
    <!-- /e jtbsm-header -->
    <div>

        <div class="mod-index-wrap">

            <!-- S 主屏背景 -->
            <div id="banner" data-rsc="9481" style=" background: linear-gradient(177deg, #FF812D 0%, #E02020 100%);height: 60px;
            z-index: 99;">

            </div>
            <!-- E 主屏背景 -->

            <div class="mod-index-main" id="js-main" style="height: 0;"></div>
        </div>

        <div class="cont cms_cont">
            <p class="new_top">
                当前位置：新闻详情 / 
                <a href="javascript: window.history.go(-1);">上一页</a>
            </p>
            <div class="news_cont">
                <div class="new_tit">
                    <div class="cms_news_tabs">
                    </div>
                    <h3>{{form.maintitle}}</h3>
                    <i class="date"> {{form.createTime | formatDate}}</i>
                </div>

                <div class="article">
                      <div v-html="form.maintext">

                      </div>
                </div>
            </div>
        </div>

    </div>
</template>
<script>
    // import $ from 'jquery';
    export default {
        data() {
            return {
               
                form: {
                    id:0,
                    maintitle:'',
                    subtitle:'',
                    maintest:'',
                    createTime:''
                },
                loading: false,
                
                currentPath: '',
                toRouter: "",
                fromRouter: ""

            }
        },
        computed: {
            noMore() {
                return this.pageNum >= this.totalPages && !this.loading
            },
            disabled() {
                return this.loading || this.noMore
            },
        },
        watch: {
            //切换路由监
            '$route'(toRouter, fromRouter) {
                this.toRouter = toRouter.params.pathMatch;
                this.currentPath = toRouter.params.pathMatch;
                this.searchMsg = toRouter.query.searchMsg;
                document.body.scrollTop = document.documentElement.scrollTop = 0;
                //this.getNewsDetails(this.currentPath, this.searchMsg, false);//初始化页面加载
            }
        },
        mounted() {
           // window.addEventListener("scroll", this.handleScroll);//滚动监听

            this.currentPath = this.$router.history.current.params.pathMatch;

            var query=this.$route.query;

            this.getNewsDetails(query.id);//初始化页面加载

        },
        methods: {
            getNewsDetails(id) {

                this.loading = true;

                let params = {};

                params.id = id;

                this.$axios.post('/api/projectApi/getNewsDetails', params).then((res) => {

                    if (res.data.code == "0") {
                        this.form = res.data.data[0];

                        this.loading = false;
                      }
                    else {
                        this.$message.error(res.data.message)
                    }
                }, (err) => {
                    this.isScroll = true;

                }).then(() => {

                }, (err) => {
                    this.loading = false;
                    this.isScroll = true;

                })
            },
            //滚动事件的监听处理
            handleScroll() {

                var scr = document.documentElement.scrollTop || document.body.scrollTop; // 向上滚动的那一部分高度
                var clientHeight = document.documentElement.clientHeight; // 屏幕高度也就是当前设备静态下你所看到的视觉高度
                var scrHeight = document.documentElement.scrollHeight || document.body.scrollHeight; // 整个网页的实际高度，兼容Pc端

                if ((scr + clientHeight + 10 >= scrHeight) && scrHeight > 700 && this.isScroll && !this.noMore && (this.searchMsg == null || this.searchMsg == "")) {

                    if (this.pageNum >= this.totalPages) {
                        return;
                    }
                    else {
                        this.isScroll = false;
                        this.pageNum++;
                        //this.getNewsDetails(this.currentPath, this.searchMsg, true);
                    }
                }

            },
            //点击记录点击量
            viewDetail(href, id, labelName) {
                // //记录连接点击量
                this.recordHits(id, labelName);

                window.open(href, 'top');

            },
            //记录点击量
            recordHits(id, labelName) {
                let params = {};
                params.id = id;
                params.labelName = labelName;
                params.ip = ('IP地址:' + returnCitySN["cip"] + ', CID:' + returnCitySN["cid"] + ', 地区:' + returnCitySN["cname"] + ",浏览器版本:" + getBrowserInfo());

                this.$axios.post('/api/projectApi/recordHits', params).then((res) => {
                    if (res.data) {
                    }
                }, (err) => {
                }).then(() => {

                }, (err) => {
                })
            },
            moreLiveInfo(pathName1, pathName2) {

                this.$router.push({
                    path: pathName2
                });
            }
        }
    }
</script>

<style scoped>
    .p-loading {

        color: #ed4856;
        font-size: 16px;
    }

    .w-980 .mod-index-list,
    .w-980 .mod-index-list .game-extend {
        width: 999px;
        background: #fff;
        border-radius: 10px;
    }

    .w-980 .game-live-item {
        width: 220px;
    }

    .live-box {
        padding: 30px 30px 5px;
        /* margin-bottom: 20px; */
    }

    .p-class {
        text-align: center;
        padding: 20px;
    }

    .jtbsm2-header.jtbsm2-header-style-skr {
        position: fixed;
    }
    .news_cont .article  p{text-indent: 2em;}
    b, strong {
        font-weight: 600;
    }
</style>